
function onPageLoad () {

    var total = 99999;
    var e = document.getElementById('current');
    total = e.getAttribute('data-total');

    var trackClock = window.setInterval(function () {
        var e = document.getElementById('sofar');
        var sofar = e.innerHTML;
        var time = sofar.split(':');
        var seconds = (time[0] * 60) + Number(time[1]) + 1;
        time[0] = (seconds / 60) | 0; // '| 0' converts to an integer
        time[1] = (seconds % 60);
        if (time[1] < 10) {
            time[1] = '0' + time[1];
        }
        sofar = time[0] + ':' + time[1];
        e.innerHTML = sofar;
        if (sofar >= total) {
            window.clearInterval(trackClock);
            window.setTimeout(function () {
                location.replace('/');
            }, 5 * 1000);       // wait for queue to update before refreshing.
        }
    }, 1000);
}

document.addEventListener("DOMContentLoaded", onPageLoad, true); 
